<template>
  <div class="header">
    <div class="background">
      <img :src='seller.avatar' />
    </div>
    <div class="content_wrapper">
      <div class="avatar">
        <img :src='seller.avatar' />
      </div>
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class="name">{{seller.name}}</span>
        </div>
        <div class="description">
          {{seller.description}}/{{seller.deliveryTime}}分钟到达
        </div>
        <div class="support"
             v-if="seller.supports">
          <span class="icon"
                :class="classMap[seller.supports[0].type]"></span>
          <span class="text">{{seller.supports[0].description}}</span>
        </div>
      </div>
      <div class="support_count"
           v-if="seller.supports">
        <span class="count"
              @click="tetailClick(true)">{{seller.supports.length}}个</span>
      </div>
    </div>
    <div class="bulletin_wrapper">
      <span class="bulletin_titlel"></span>
      <span class="bulletin_text">{{seller.bulletin}}</span>
      <div class=""></div>
    </div>
    <div class="detail"
         v-show="detailshow"
         @click="tetailClick(false)">
      <div class="detail_wrapper">
        <div class="detail_main">
          <div class="name">{{seller.name}}</div>
          <div class="star_wrapper">
            <star :score="seller.score"
                  :size="48"></star>
          </div>
          <div class="title">
            <div class="line"></div>
            <div class="text">优惠信息</div>
            <div class="line"></div>
          </div>
          <ul class="supports">
            <li v-for="(item,index) in seller.supports"
                :key="index"
                class="support">
              <span class="icon"
                    :class="classMap[item.type]"></span>
              <span class="text">{{item.description}}</span>
            </li>
          </ul>
          <div class="title">
            <div class="line"></div>
            <div class="text">商家信息</div>
            <div class="line"></div>
          </div>
          <div class="content">
            <p>{{seller.bulletin}}</p>
          </div>
        </div>
      </div>
      <div class="detail_close">
        <span class="icon-close"></span>
      </div>
    </div>
  </div>
</template>
<script>
import star from '../star/star.vue'
export default {
  components: { star },
  props: ['seller'],
  data () {
    return {
      detailshow: false,
      classMap: ['decrease', 'discount', 'guarantee', 'invoice', 'special']
    }
  },
  methods: {
    tetailClick (flag) {
      this.detailshow = flag
    }
  }
}
</script>
<style lang="stylus" rel="stylesheet/stylus">
@import '../../common/stylus/mixins.styl';

.header {
  position: relative; // 相对定位
  background: rgba(7, 17, 27, 0.5); // 设置背景颜色 透明度
  color: white;
  overflow: hidden; // 内容超出框体后 ：隐藏超出部分

  .background {
    position: absolute; // 绝对定位
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1; // 设置层级在最底层

    img {
      width: 100%;
      height: 100%;
    }
  }

  .content_wrapper {
    position: relative;
    padding: 24px 24px 24px 24px; // 上右下左边距 如果只设置上右 ，则下左会保持上右一样大小

    .avatar {
      display: inline-block; // 转换为行内块标签
      width: 64px;
      height: 64px;

      img {
        width: 100%;
      }
    }

    .content {
      display: inLine-block;
      margin-left: 16px; // 单独设置左边距
      padding: 2px 0 2px;

      .title {
        .brand {
          display: inLine-block;
          width: 30px;
          height: 18px;
          background-repeat: no-repeat; // 背景图填充方式 ：只显示一张 repeat会在垂直和水平放心填充  repeat-x  repeat-y只在对应放心填充
          background-size: 30px 18px;
          vertical-align: middle;
          bg_image(brand);
        }

        .name {
          margin-left: 6px;
          font-size: 16px; // 字体大小
          line-height: 18px; // 上下行间距
          font-weight: bold; // 字体粗细。bold： 粗，bolder： 更粗， lighter： 细， 100-900 ：根据值决定粗细
        }
      }

      .description {
        margin-top: 10px;
        font-size: 12px;
        font-weight: 200;
        line-height: 12px;
      }

      .support {
        margin-top: 10px;

        .icon {
          display: inline-block;
          width: 12px;
          height: 12px;
          background-size: 12px 12px;
          background-repeat: no-repeat;
          vertical-align: middle;
        }

        .decrease {
          bg_image(decrease_1);
        }

        .discount {
          bg_image(discount_1);
        }

        .guarantee {
          bg_image(guarantee_1);
        }

        .text {
          margin-left: 4px;
          font-size: 12px;
          font-weight: 200;
          line-height: 12px;
        }

        .invoice {
          bg_image(invoice_1);
        }

        .special {
          bg_image(special_1);
        }
      }
    }

    .support_count {
      display: inLine-block;
      background: rgba(0, 0, 0, 0.2);
      border-radius: 8px; // 圆角边
      position: absolute; // 绝对定位 相对父级
      right: 12px;
      bottom: 18px;
      height: 24px;
      padding: 4px 8px;

      // box-sizing: border-box;
      .count {
        font-size: 10px;
        font-font-weight: 200;
      }
    }
  }

  .bulletin_wrapper {
    position: relative;
    padding: 0px 12px;
    white-space: nowrap; // 文本不换行 除非遇到br
    overflow: hidden; // 超出不显示
    text-overflow: ellipsis; /* *文本超出后ellipsis显示省略符号来代表被修剪的文本。string使用给定的字符串来代表被修剪的文本。* */
    height: 28px;
    line-height: 28px;

    .bulletin_titlel {
      display: inline-block;
      width: 22px;
      height: 12px;
      background-repeat: no-repeat; // 不进行填充
      background-size: 22px 12px;
      vertical-align: middle;
      bg_image(bulletin);
    }

    .bulletin_text {
      margin: 0px 4px;
      font-size: 10px;
      font-font-weight: 200;
    }
  }

  .detail {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(7, 17, 27, 0.9);
    z-index: 100;

    .detail_wrapper {
      height: 70%;
      padding: 60px 0 40px 0;

      .detail_main {
        .name {
          text-align: center;
          line-height: 16px;
          font-size: 16px;
          margin-bottom: 16px;
        }

        .star_wrapper {
          height: 24px;
          text-align: center;
        }

        .title {
          padding: 28px 36px 24px;
          display: flex;

          .line {
            flex: 1;
            position: relative;
            top: 6px;
            width: 100px;
            height: 2px;
            background: rgba(255, 255, 255, 0.2);
          }

          .text {
            float: left;
            margin: 0 12px;
          }
        }

        .supports {
          padding: 0 48px;

          .support {
            margin-bottom: 12px;

            .icon {
              display: inline-block;
              width: 16px;
              height: 16px;
              background-size: 16px 16px;
              background-repeat: no-repeat;
              vertical-align: middle;
            }

            .decrease {
              bg_image('decrease_2');
            }

            .discount {
              bg_image('discount_2');
            }

            .guarantee {
              bg_image('guarantee_2');
            }

            .invoice {
              bg_image('invoice_2');
            }

            .special {
              bg_image('special_2');
            }
          }
        }

        .content {
          padding: 0 48px;
          line-height: 24px;
          font-size: 12px;
          font-weight: 200;
        }
      }
    }

    .detail_close {
      text-align: center;
      line-height: 32px;
      font-size: 32px;
      color: rgba(255, 255, 255, 0.5);
    }
  }
}
</style>
